<div>
	<form method="post" id="brand" name="brand">
    <table class="form-table" cellspacing="1" cellpadding=3 width="100%" >
    	<tr>
    		<td width="19%" align="left">
	    		<select id="brandList" multiple="true" name="brandList" style="width:200px; height:300px;" >
	    			<#if brands??>
	    				<#list brands as brand>
	    					<option value="${brand.id}">${brand.name}</option>
	            		</#list>
	    			</#if>
	            </select>
	    	</td>
	    	<td width="13%" align="center">
	    		<input name="submit" type="button" class="button" value=" -> " onClick="addLink()">
            	<br/>
            	<input name="submit" type="button" class="button" value=" <- " onClick="removeLink()">
	    	</td>
	    	<td width="68%" align="left">
	    		<select id="chhoose_brands" multiple="true" name="chhoose_brands" style="width:200px; height:300px; " >
	            	<#if brandLinks??>
	    				<#list brandLinks as link>
	    					<option value="${link.brand.id}">${link.brand.name}</option>
	            		</#list>
	    			</#if>
	            </select>
	    	</td>
    	</tr>
    </table>
	</form>
</div>


<script type="text/javascript">
	function addLink(){
		var checkIndex = $("#brandList").get(0).selectedIndex;
		var text = $("#brandList").find("option:selected").text();
		var value = $("#brandList").find("option:selected").val();
		if(!isExistOption(value)){
			$("#chhoose_brands").append('<option value="'+value+'">'+text+'</option>');	
		}
		
	}
	
	function removeLink(){
		var checkIndex = $("#chhoose_brands").get(0).selectedIndex;
		//$("#chhoose_brands option[index='0']").remove();
		$("#chhoose_brands").find("option").filter(":eq("+checkIndex+")").remove();
	}
	
	function isExistOption(value){
		if(!value){
			return true;
		}else{
			var isExist = false;
			var count = $("#chhoose_brands").find("option").length;
			for(var i=0;i<count;i++){
				if($("#chhoose_brands").get(0).options[i].value==value){
					isExist = true;
					break;
				}
			}
			return isExist;
		}
		
	}	
</script>